package com.situ.day8.jdbc;

//账户管理
public class AccountManager {
    //余额
    private Double balance;

    public AccountManager(Double balance) {
        this.balance = balance;
    }

    //存钱
    public void deposit(Double money) {
        balance += money;
    }

    //取钱
    public void withdraw(Double money) throws MeiQianException {
        if (balance >= money) {
            balance -= money;
        } else {
            Double needMoney = money - balance;
            throw new MeiQianException("余额不足，还差：" + needMoney);
        }
    }

    public static void main(String[] args) {
        AccountManager accountManager = new AccountManager(800.0);
        try {
            accountManager.withdraw(1000.0);
        } catch (MeiQianException e) {
            e.printStackTrace();
        }
    }

}
